package com.tzy.nowcoder.leetcode;

import java.util.Scanner;

/**
 * HJ6 质数因子
 */
public class Hj6 {
    static class Test{
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);

            long num = scanner.nextLong();
            long k = (long) Math.sqrt(num);

            for (long i = 2; i <= k; ++i) {
                while (num % i == 0) {
                    System.out.print(i + " ");
                    num /= i;
                }
            }
            System.out.println(num == 1 ? "": num+" ");
        }
    }
    public static void main(String[] args) {
//        System.out.println(getResult(180));;
        getNum();
    }
    static void getNum(){

        Scanner input = new Scanner(System.in);
        //但是正如我们判断数 num 是不是质数时，没必要从 2 一直尝试到 num 一样，
        // 此题中的大循环也大可不必写一个到 num 的循环，写到 \sqrt{num}
        //  即可，如果此时数字还没有除数，则可判定其本身是一个质数，没有再除下去的必要了，直接打印其本身即可：
        //接收一个数Long
        //判断取模是否等于0,否则质数因子加一
        //取模等于0,并且质数因子等于nextLong,完成,追加到sb,否则nextLong /=index
        //用例输入: 2000000014
        long num = input.nextLong();
        long sqrt = (long)Math.sqrt(num);
        StringBuilder sb = new StringBuilder();
        int index =2;//初始质数因子
        for (int i = 2; i <= sqrt; i++) {
            while(num % i == 0){
                System.out.print(i+" ");
                num = num / i;
            }
        }
        System.out.print(num == 1 ? "": num+" ");
//        while (index<=sqrt){
//            if( num % index ==0 ){
////                if(index==num){
////                    sb.append(index).append(" ");
////                    break;
////                }else{
//                    sb.append(index).append(" ");
//                    num = num / index;
////                    System.out.println("num="+num);
////                }
//            }else{
//                index++;
////                System.out.println("index="+index);
//            }
//        }
        //用例输入: 2000000014
        //"质数因子:"+
//        System.out.println(sb);
    }
    /**
     * 原文链接：https://blog.csdn.net/qingmengwuhen1/article/details/82697979
     */
    public static String getResult(long ulDataInput) {
        StringBuilder sb = new StringBuilder();
        int index = 2;
        while (index <= ulDataInput) {
            if (ulDataInput % index == 0) {
                if (index == ulDataInput) {
                    sb.append(index).append(" ");
                    break;
                } else {
                    sb.append(index).append(" ");
                    ulDataInput = ulDataInput / index;
                }
            } else {
                index++;
            }
        }
        return sb.toString();
    }


}
